/**
 * Copyright &copy; 2012-2014 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.tgsoft.gfrm.modules.sys.web;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.tgsoft.gfrm.modules.sys.service.UserService;
import com.tgsoft.gfrm.sys.entity.SysUser;



/**
 * LoginController负责打开登录页面(GET请求)和登录出错页面(POST请求)，
 * 
 * 真正登录的POST请求由Filter完成,
 * 
 * @author calvin
 */
@Controller
@RequestMapping(value = "/main")
public class MainController {

	@Autowired
	private UserService userService;

	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public String showUserInfo(SysUser user, Model model) {
		List<SysUser> lstUsers=userService.getAllUser();
		model.addAttribute("lstUsers",lstUsers) ;
		return "/list";
	}

	@RequestMapping(value = "/error", method = RequestMethod.GET)
	public String error(SysUser user, Model model) {
		return "/error/500";
	}
	
	
	@RequiresRoles("admin")
	@RequiresPermissions("view")
	@RequestMapping(value = "/listusr", method = RequestMethod.GET)
	public String lstusr(SysUser user, Model model) {
		List<SysUser> lstUsers=userService.getAllUser();
		model.addAttribute("lstUsers",lstUsers) ;
		return "/listusr";
	}
	
}